<?php

namespace app\index\validate;
use think\Validate;

class IndexValidate extends Validate
{
    protected $rule = [
        'userName' => 'require',
        'password' => 'require|min:6',
        'phone'    =>  'require',
        'dishName' => 'require',
        'targetDate' => 'require',
        'dishLimit' =>  'require|integer'
    ];

    protected $message = [
        'userName.require' => '用户名不能为空',
        'password.require' => '密码不能为空',
        'password.min' => '密码长度不能小于6',
        'phone' =>  '手机号不能为空',
        'dishName.require' => '菜品名称不能为空',
        'targetDate.require' => '生效日期不能为空',
        'dishLimit.require' =>  '点击数量不能为空',
        'dishLimit.integer' =>'积分必须为整数'
    ];

    // 自定义验证场景
    protected $scene = [
        'register'  => ['username', 'password','phone'],
        'login'  => ['username', 'password'],
        'orderPost' => ['dishName','targetDate','dishLimit'],
        'delete' => ['id']
    ];
}